import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/lget/lget.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:ladder_cash/app/page/home/home_page.dart';
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/value/app_colors.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import '../../../gen/assets.gen.dart';
import '../component/common.dart';

class GuidePage extends StatefulWidget {
  GuidePage({super.key});

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<GuidePage> {
  var pageController = PageController();

  @override
  void initState() {
    super.initState();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    // precacheImage(const AssetImage(Assets.molopNew1mx), context);
    // precacheImage(const AssetImage(Assets.molopNew2mx), context);
    // precacheImage(const AssetImage(Assets.molopNew3mx), context);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: PageView(
        controller: pageController,
        children: [pageItemView(0), pageItemView(1)], //, pageItemView(2)
      ),
    );
  }

  Widget pageItemView(int index) {
    return LContainer(
      lStyle: LStyle(),
      child: LStack([
        Image.asset('${Assets.splash.splash9528bg.path}',
            width: Get.width, height: Get.height, fit: BoxFit.fill),
        Positioned(
            top: LGet.startBarHeight + 60.w,
            left: 16.w,
            right: 16.w,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Image.asset(
                  "${index == 0 ? Assets.splash.splash9528people.path : Assets.splash.splash9529people.path}",
                  width: 193.w,
                  height: 246.w,
                ),
                LSizeH(41.w),
                Text(
                  "${index == 0 ? S.current.fastApproval : S.current.dataEncryption}",
                  style: TextStyle(fontSize: 26),
                ),
                LSizeH(21.w),
                Text(
                  "${index == 0 ? S.current.withThe : S.current.advancedData}",
                  style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
                ),
              ],
            )),
        // LExpand(),
        Positioned(
            right: 16.w,
            left: 16.w,
            bottom: LGet.bottomPadding(context) + 35.w,
            child: Container(
              height: 80.w,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  if (index == 0)
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Image.asset(
                          "${Assets.splash.splash9528bar.path}",
                          width: 20.w,
                          height: 4.w,
                        ),
                        Image.asset(
                          "${Assets.splash.splash95281bar.path}",
                          width: 12.w,
                          height: 4.w,
                        ),
                      ],
                    ),
                  if(index ==1) Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Image.asset(
                        "${Assets.splash.splash95281bar.path}",
                        width: 12.w,
                        height: 4.w,
                      ),
                      Image.asset(
                        "${ Assets.splash.splash9528bar.path}",
                        width: 20.w,
                        height: 4.w,
                      ),

                    ],
                  ),
                  Container(
                    height: 46.w,
                    child: commonBtn(index == 0 ? S.current.next : S.current.start,
                      callback: () {
                        if (index == 1) {
                          Get.offAll(HomePage());
                        } else {
                          pageController.jumpToPage(index + 1);
                        }
                      }),)
                ],
              ),
            )),
        // LSizeH(87.h)
        // ..asWidget().position(bottom: 60.w, left: 120.w)
      ]),
    );
  }

  LStyle get btnStyle => LStyle(
      height: 58.w,
      width: 170.w,
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(12.w), bottomRight: Radius.circular(12.w)),
      backgroundColor: AppColors.primaryColor,
      alignment: Alignment.center,
      fontSize: 16.sp,
      color: Colors.white,
      fontWeight: FontWeight.w900);

  LStyle get btnBlackStyle => LStyle(
      height: 58.w,
      width: 170.w,
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(12.w), bottomRight: Radius.circular(12.w)),
      backgroundColor: const Color(0xFF191932),
      alignment: Alignment.center,
      fontSize: 16.sp,
      color: Colors.white,
      fontWeight: FontWeight.w900);

  @override
  void dispose() {
    super.dispose();
  }
}
